
#ifndef TOX_MSG_PRASE_H
#define TOX_MSG_PRASE_H


#include <algorithm>
#include <bitset>
#include <iostream>
#include "byte_decode.h"

namespace tbox_msg
{

  //"L  0-1：0：无效；1：L
  // MY  0-7：01：盛达；02：牧原
  // 1 0-15:01:消毒、02-育肥 ,读到01 转成1
  // C 0-15：01：配置A，02：配置B，03：配置C
  // 22  0-31：22：22年，23：23年，24：24年
  // C  0-31：01：生产线A；2：生产线B....
  // 00001"; 0-65535：00001：1号车，00002：2号车....
  const std::string vin_country_code_s[2] = {"N", "L"};
  const std::string vin_oem_s[5] = {"*", "SD", "MY"};
  const std::string vin_vehicle_config_s[10] = {"*", "A", "B", "C", "D", "E", "F", "G"};
  const std::string vin_assembly_plant_code_s[10] = {"*", "A", "B", "C", "D", "E", "F", "G", "H", "I"};
  const std::string devel_stage_s[8] = {"*", "A", "B", "C", "D", "E", "F", "G"};
  const std::string vehicle_type_s[32] = {"*", "XD", "YF", "WZ", "*", "*", "*"};

  class parse_vin
  {
  private:
    int development_stage_;
    int vehicle_model_;
    int major_version_;
    int minor_version_;
    int vin_country_code_;
    int vin_oem_;
    int vin_vehicle_type_;
    int vin_vehicle_config_;
    int vin_year_of_production_;
    int vin_assembly_plant_code_;
    int vin_serial_number_;
    std::string software_version;
    std::string vin;

  public:
    parse_vin(/* args */);
    ~parse_vin();

    std::string majorVersion;
    std::string minorVersion;
    std::string softwareVersion;
    std::string sequenceNum;
    std::string VIN;

    void parse(const std::uint8_t *bytes, const int32_t length);
    int development_stage(const std::uint8_t *bytes, const int32_t length);
    int vehicle_model(const std::uint8_t *bytes, const int32_t length);
    int major_version(const std::uint8_t *bytes, const int32_t length);
    int minor_version(const std::uint8_t *bytes, const int32_t length);
    int vin_country_code(const std::uint8_t *bytes, const int32_t length);
    int vin_oem(const std::uint8_t *bytes, const int32_t length);
    int vin_vehicle_type(const std::uint8_t *bytes, const int32_t length);
    int vin_vehicle_config(const std::uint8_t *bytes, const int32_t length);
    int vin_year_of_production(const std::uint8_t *bytes, const int32_t length);
    int vin_assembly_plant_code(const std::uint8_t *bytes, const int32_t length);
    int vin_serial_number(const std::uint8_t *bytes, const int32_t length);
  };

}

#endif
